CentOS 7
Sponsored Link

Docker : Install
2015/01/10
 
Install Docker which is the Operating System-Level Virtualization Tool, which automates the deployment of applications inside Containers.
[1] Install Docker.
[root@dlp ~]#
yum -y install docker
[root@dlp ~]#
systemctl start docker

[root@dlp ~]#
systemctl enable docker

[2] Download the official image and create a Container and output the words "Welcome to the Docker World" inside the Container.
# download a centos image

[root@dlp ~]#
docker pull centos

Trying to pull repository docker.io/library/centos ...
latest: Pulling from library/centos
47d44cb6f252: Extracting     32 B/32 B
...
...
# run echo inside Container

[root@dlp ~]#
docker run centos /bin/echo "Welcome to the Docker World"

Welcome to the Docker World
[3] Connect to the interactive session of a Container with "i" and "t" option like follows. If exit from the Container session, the process of a Container finishes.
[root@dlp ~]#
docker run -i -t centos /bin/bash

[root@06c8cbea8dc3 /]#    
# Container's console
bash-4.3#
uname -a

Linux 06c8cbea8dc3 3.10.0-123.13.2.el7.x86_64 #1 SMP Thu Dec 18 14:09:13 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@06c8cbea8dc3 /]#
exit

exit
[root@dlp ~]#    
# back
[4] If exit from the Container session with keeping container's process, push Ctrl+p, and Ctrl+q key.
[root@dlp ~]#
docker run -i -t centos /bin/bash

[root@64241ed538ed /]# [root@dlp ~]#    
# Ctrl+p, Ctrl+q key to back to Host's console
[root@dlp ~]#
docker ps
   
# show docker process

CONTAINER ID   IMAGE      COMMAND       CREATED         STATUS         PORTS  NAMES
64241ed538ed   centos:7   "/bin/bash"   35 seconds ago  Up 34 seconds         clever_bartik

# connect to container's session

[root@dlp ~]#
docker attach 64241ed538ed

[root@64241ed538ed /]#    
# connected
# shutdown container's process from Host's console

[root@dlp ~]#
docker kill 64241ed538ed

[root@dlp ~]#
docker ps

CONTAINER ID    IMAGE          COMMAND       CREATED          STATUS          PORTS     NAMES
 
Tweet